<template>
  <div
    class="wrapper"
    :class="$nuxt.$route.path == '/merchant/merchant/category' ? 'wrapper' : ''"
  >
    <div
      @click="goDetail(item)"
      class="goods_item"
      :class="
        $nuxt.$route.path == '/'
          ? 'imgItem1'
          : $nuxt.$route.path == '/merchant/merchant/home'
          ? 'imgItem2'
          : $nuxt.$route.path == '/merchant/merchant/category'
          ? 'imgItem3'
          : 'imgItem1'
      "
      v-for="item in productList"
      :key="item.id"
    >
      <el-image :src="item.image" fit="scale-down">
        <div slot="placeholder" class="image-slot">
          loading<span class="dot">...</span>
        </div>
      </el-image>
      <div class="goods_content">
        <div
          class="lines2"
          :class="$nuxt.$route.path == '/' ? 'store_name1' : 'store_name'"
        >
          {{ item.storeName }}
        </div>
        <div
          class="acea_row"
          :class="$nuxt.$route.path == '/' ? 'acea_row1' : ''"
        >
          <div class="price">
            <statistic :value="item.price" :currency="item.currency" />
          </div>
          <div v-if="$nuxt.$route.path == '/'" class="ot_price1">
            <span class="sold">
              {{ Math.floor(item.sales) + Math.floor(item.ficti) || 0 }}
              {{ $t(`page.goodsDetail.sold`) }}
            </span>
          </div>
          <div v-if="$nuxt.$route.path !== '/'" class="ot_price">
            <span v-if="$nuxt.$route.path !== '/'" class="lines">
              <statistic
                :valueStyle="{ color: '#999', textDecoration: 'line-through' }"
                :value="item.otPrice"
                :currency="item.currency"
              />
            </span>
            <span
              >{{ Math.floor(item.sales) + Math.floor(item.ficti) || 0 }}
              {{ $t(`page.goodsDetail.sold`) }}</span
            >
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { goShopDetail } from "@/utils/order.js";
export default {
  name: "product",
  props: {
    productList: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  methods: {
    goDetail(item) {
      goShopDetail(item.id, this);
    },
  },
};
</script>
<style lang="scss" scoped>
@import "@/assets/css/variables.scss";
.wrapper {
  display: grid;
  grid-column-gap: 16px;
  grid-row-gap: 24px;
  grid-template-columns: repeat(5, 1fr);
}

.imgItem1 {
  &:nth-child(5n) {
    margin-right: 0;
  }
}
.imgItem2 {
  // width: 284px;
  // height: 390px;
  // margin-right: 20px;

  // &:nth-child(4n) {
  //   margin-right: 0;
  // }

  // .el-image {
  //   width: 244px;
  //   height: 244px;
  // }
}
.imgItem3 {
  width: 225px;
  height: 355px;
  margin: 0;

  &:nth-child(4n) {
    width: 240px;
    padding-right: 15px;
  }

  .el-image {
    width: 210px;
    height: 210px;
    margin: 15px 0 8px 15px;
  }
}

.goods_item {
  display: inline-block;
  background: #ffffff;
  cursor: pointer;

  &:hover {
    .img,
    .el-image {
      box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.2);
    }
  }

  .img,
  .el-image {
    margin-bottom: 12px;
    border: 1px solid $use-color-line;
    border-radius: 8px;
    width: 218px;
    height: 218px;
  }

  .goods_content {
    .store_name {
      height: 44px;
      margin: 0 0 20px 0x;
      font-size: 16px;
      color: #333333;
      line-height: 22px;
    }

    .store_name1 {
      height: 48px;
      font-size: 16px;
      color: #333333;
      line-height: 24px;
    }

    .lines2 {
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
  }

  .acea_row1 {
    display: flex;
  }

  .acea_row {
    padding-top: 6px;
    justify-content: space-between;
    align-items: center;
    display: flex;

    .price {
      font-size: 20px;
      font-weight: 900;
      color: $user--color-price;
      line-height: 20px;
      margin-bottom: 9px;
      display: inline-block;

      .sold {
        font-size: 12px;
        color: #999999;
        margin-right: 15px;
      }
    }

    .ot_price {
      font-size: 12px;
      font-weight: 400;
      color: #888888;
      line-height: 12px;
      display: flex;
      justify-content: space-between;

      .lines {
        text-decoration: line-through;
      }
    }

    .ot_price1 {
      font-size: 12px;
      font-weight: 400;
      color: #999999;
      line-height: 29px;

      .lines {
        text-decoration: line-through;
      }
    }
  }
}
</style>
